package com.zzptc.syl.traffic;

import android.content.Context;
import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.VideoView;

import java.util.List;
import java.util.concurrent.BlockingDeque;

import static androidx.constraintlayout.motion.utils.Oscillator.TAG;

public class VideoAdapter extends BaseAdapter {
    private List<Uri> mData;
    private Context mContext;

    public VideoAdapter(List<Uri> mData, Context mContext) {
        this.mData = mData;
        this.mContext = mContext;
    }
    @Override
    public int getCount() {
        Log.d(TAG, "getCount: "+mData.size());
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(mContext).inflate(R.layout.layout_video,viewGroup,false);
        VideoView videoView = view.findViewById(R.id.VV_1);
        videoView.setVideoURI(mData.get(i));
        videoView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                videoView.start();
            }
        });
        return view;
    }
}
